package com.fortune.rainshinecommon.base;

import com.fortune.rainshinecommon.enums.RespStatusEnum;

import java.io.Serializable;

public class MsgModel<T> implements Serializable {

    private static final long serialVersionUID = 4054892350748145972L;

    /**
     * @Fields msg : 消息
     */
    private String msg;
    /**
     * @Fields status : 调用状态 0.成功 1.失败
     */
    private Integer status=0;
    /**
     * @Fields code : 状态编码
     */
    private String code;
    /**
     * @Fields data : 返回数据
     */
    private T data;



    public MsgModel(){

    }
    public MsgModel(String msg){
        this.msg=msg;
    }
    public MsgModel(String msg,Integer status){
        this.msg=msg;
        this.status=status;
    }
    public MsgModel(String msg,RespStatusEnum statusEnum){
        this.msg=msg;
        this.status=statusEnum.ordinal();
    }
    public MsgModel(String msg,Integer status,T data){
        this.msg=msg;
        this.status=status;
        this.data=data;
    }
    public MsgModel(String msg, RespStatusEnum statusEnum, T data){
        this.msg=msg;
        this.status=statusEnum.ordinal();
        this.data=data;
    }
    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public T getData() {
        return data;
    }
    public void setData(T data) {
        this.data = data;
    }

    public boolean isSuccess(){
        if(RespStatusEnum.SUCCESS.ordinal() == status || RespStatusEnum.SUCCESS.ordinal() == status.intValue()){
            return true;
        }
        return false;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
}
